
import { SymbolOrderMoreConfig } from "../module/symbol-order-config/SymbolOrderConfig.entity";
import { OrderSide, PositionSide } from "../lib/quant";
import { Period } from "./PeriodProcess";
import { CustomIndicators } from "./MixIndicator";

export declare type numberInString = string | number;
export declare type OrderStatus = 'NEW' | 'PARTIALLY_FILLED' | 'FILLED' | 'CANCELED' | 'PENDING_CANCEL' | 'REJECTED' | 'EXPIRED';

export interface SymbolBalance {
    /** 账户唯一识别码 */
    accountAlias: string;
    /** 资产 */
    asset: string;
    /** 账户余额 */
    balance: string;
    /** 最大可提款金额 */
    maxWithdrawAmount?: string;
    /** 全仓账户余额 */
    crossWalletBalance: string;
    /** 全仓持仓未实现盈亏 */
    crossUnPnl: string;
    /** 可用下单余额 */
    availableBalance: string;
}

export interface OrderResult {
    avgPrice: numberInString;
    price: numberInString;
    side: OrderSide;
    positionSide: PositionSide;
    status: OrderStatus;
    activatePrice: numberInString;
}
export interface SpotOrder {
    status: OrderStatus;
}


export type AutoTradeType = "spot" | "futures" | "delivery"


export interface AutoOrderConfig{
  id: number;
  symbol: string;
  buy_usdt?: number;
  sell_usdt?: number;
  period?: Period;
  /** 买入开多 */
  open_long: number;
  /** 卖出平多 */
  close_long: number;
  /** 卖出开空 */
  open_short: number;
  /** 买入平空 */
  close_short: number;

  lever_rate: number;
  order_type: "MARKET" | "LIMIT";
  trade_type: AutoTradeType
  config: SymbolOrderMoreConfig
  userid: number
}

export interface ExchangeTrader {
    getSpotBalance(symbol?: string): Promise<{ free: string } | Record<string, { free: string }>>;
    getFuturesBalance(symbol?: string): Promise<SymbolBalance | Record<string, SymbolBalance>>;
    getDeliveryBalance(symbol?: string): Promise<SymbolBalance | Record<string, SymbolBalance>>;

    getSpotOrder(symbol: string, id: numberInString): Promise<SpotOrder>;
    getFuturesOrder(symbol: string, id: numberInString): Promise<OrderResult>;
    getDeliveryOrder(symbol: string, id: numberInString): Promise<OrderResult>;
}

export interface MixIndicatorsTolerance extends Pick<CustomIndicators, 
  | "slope_15m"
  | "slope_4h"
  | "slope_1d"
  | "change_rate_15m"
  | "close_ma_rate_15m"
  | "close_ma_rate_4h"
  | "close_ma_rate_1d"
  | "volume_rate_15m"
  | "volume_rate_4h"
  | "volume_rate_1d"
  | "exceptional_undulation_rate_15m"
  | "exceptional_undulation_rate_4h"
  | "exceptional_undulation_rate_1d"
  | 'vector_stort_15m'
  // | "sum_slope_rate_15m"
  // | "sum_slope_rate_4h"
  // | "sum_slope_rate_1d"
  // | "volatility_15m"
  // | "volatility_4h"
  // | "volatility_1d"
> {
  //
}
